package com.example.lijinyuan.baseandroid.BroadcastReceive;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;

import com.example.lijinyuan.baseandroid.R;

/**
 * Created by lijinyuan on 15/11/28.
 */
public class Broadcast extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.broadcast_activity);
        IntentFilter intentFilter = new IntentFilter("sendDynamic");
        BroadDynamic broadDynamic = new BroadDynamic();
        registerReceiver(broadDynamic, intentFilter);

    }

    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.send:
                Intent intent = new Intent();
                intent.putExtra("send", "这是一条普通的广播");
                intent.setAction("send");
                sendBroadcast(intent);
                break;
            case R.id.sendPriority: Intent intent3 = new Intent();
                intent3.putExtra("sendPriority", "这是一条普通有顺序的广播");
                intent3.setAction("sendPriority");
                sendBroadcast(intent3);
                break;


            case R.id.sendDynamic:
                Intent intent4 = new Intent();
                intent4.putExtra("sendDynamic", "这是一条动态的广播");
                intent4.setAction("sendDynamic");
                sendBroadcast(intent4);
                break;
            case R.id.sendOrdered:
                Intent intent2 = new Intent();
                intent2.putExtra("sendOrdered", "这是一条有序的广播");
                intent2.setAction("sendOrdered");
                sendOrderedBroadcast(intent2,null);
                break;
        }

    }
}
